/**
 * There are code generation
 */
package com.neusoft.lohas.modules.ivm.service.order;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.lohas.common.service.BaseService;
import com.neusoft.lohas.modules.ivm.dao.order.PromptDao;
import com.neusoft.lohas.modules.ivm.entity.merchant.Merchant;
import com.neusoft.lohas.modules.ivm.entity.order.Prompt;

/**
 * 温馨提示Service
 * @author Jackie.Liu
 * @version 2015-03-02
 */
@Component
@Transactional(readOnly = true)
public class PromptService extends BaseService {

	@Autowired
	private PromptDao promptDao;
	
	public Prompt get(String id) {
		return promptDao.get(id);
	}
	
	@Transactional(readOnly = false)
	public void save(Prompt prompt) {
		promptDao.save(prompt);
	}
	
	@Transactional(readOnly = false)
	public void delete(String id) {
		promptDao.deleteById(id);
	}

	public Prompt findByMerchantId(String merchantId) {
		Prompt prompt = promptDao.findByMerchantId(merchantId);
		if (prompt == null) {
			prompt = new Prompt();
			prompt.setMerchant(new Merchant(merchantId));
		}
		return prompt;
	}
}
